feat(testkit): add API-token login flow#46
Conversation
Kusari Analysis Results:
Both dependency and code analyses returned clean results. (1) Dependency Analysis: No pinned version dependency changes were detected, presenting no dependency-related security concerns. (2) Code Analysis: All medium-severity scanner findings were confirmed as false positives upon manual review. CSRF protection is properly implemented in Go templates via csrf.go and hidden token inputs in both login.html and new.html. The flagged open redirect at handlers.go:147 uses a database-generated ID rather than user-supplied input and is not exploitable. Both XSS findings are non-issues: one write uses plainContentType preventing browser HTML interpretation, and the other uses Go's html/template package with automatic escaping via a buffered rendering pattern. Low-severity cookie Secure flag findings are excluded per policy. No secrets or workflow issues were detected. The combined risk profile presents no actionable security concerns blocking this PR. Note View full detailed analysis result for more information on the output and the checks that were run.
Found this helpful? Give it a 👍 or 👎 reaction! |
| <p class="error" role="alert">{{.Error}}</p> | ||
| {{end}} | ||
|
|
||
| <form class="paste-form auth-form" method="post" action="/auth/token"> |
There was a problem hiding this comment.
Issue: The login form is missing a CSRF token. Implement a CSRF token mechanism in your Go HTTP handlers (e.g., using the gorilla/csrf middleware or a custom implementation) and embed the token in the form.
Recommended Code Changes:
<form class="paste-form auth-form" method="post" action="/auth/token">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<label>
API token
<input name="api_token" type="password" required autofocus autocomplete="off">
</label>
<button type="submit">Continue</button>
</form>
| <p class="error" role="alert">{{.Error}}</p> | ||
| {{end}} | ||
|
|
||
| <form class="paste-form" method="post" action="/pastes"> |
There was a problem hiding this comment.
Issue: The paste creation form is missing a CSRF token. Add a hidden CSRF token field and validate it server-side on POST requests.
Recommended Code Changes:
<form class="paste-form" method="post" action="/pastes">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<label>
Title
<input name="title" value="{{.Form.Title}}" maxlength="120" autocomplete="off">
</label>
ef85330 to
7405c8f
Compare
|
Kusari PR Analysis rerun based on - 7405c8f performed at: 2026-05-14T21:16:53Z - link to updated analysis |
Summary
Validation